package com.shenzhenai.module_design_partterns.class1;

/**
 * 1、设计模式 - 简单工程模式
 * https://www.bilibili.com/video/BV1et3MzxEgJ/?spm_id_from=333.337.search-card.all.click&vd_source=e07cc8cc94eb22bd76722071b03cd199
 */
public class MainApp {
    public static void main(String[] args) {
        double price = 1;
        int count = 2;
        int type = 3;

        CashSuper cashSuper = CashFactory.createCashAdapter(getDisCountText(type));

        // 计算费用并应用折扣
        double cost = cashSuper.acceptCash(price * count);

        System.out.println("单价: " + price + ", 数量：" + count + ", 折扣：" + getDisCountText(type) + ", 费用：" + cost);
    }

    private static String getDisCountText(int type) {
        String disCountText = "";
        switch (type) {
            case 1:
                disCountText = "正常消费";
                break;
            case 2:
                disCountText = "满300返100";
                break;
            case 3:
                disCountText = "打8折";
                break;
            default:
                break;
        }
        return disCountText;
    }
}